﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;

namespace MapControl.Misc.GPSPoint
{
    /// <summary>
    /// Class dùng để vẽ tọa độ GSP mới nhất
    /// </summary>
    public class GPSCurrentPoint : BaseGPSPoint
    {
        //public GPSCurrentPoint()
        //    : base()
        //{

        //}

        //public GPSCurrentPoint(AxMapXLib.AxMap map)
        //    : base(map)
        //{
        //}

        //public GPSCurrentPoint(AxMapXLib.AxMap map, string name, DateTime local, double lon, double lat, double alt, double speed, double angle)
        //    :base(map,name,local,lon,lat,alt,speed, angle)
        //{

        //}

        public GPSCurrentPoint(AxMapXLib.AxMap map, DataRow row)
            : base(map, row)
        {

        }

        

        #region Override Functions

        //protected override void InitRect()
        //{
        //    r = 0.02f;
        //    float x1, y1, x2, y2, centerX, centerY;
        //    x1 = y1 = x2 = y2 = centerX = centerY = 0;
        //    double lon1, lat1, lon2, lat2;
        //    lon1 = objGPSData.LonGPS - r;
        //    lat1 = objGPSData.LatGPS + 3 * r;
        //    lon2 = objGPSData.LonGPS + r;
        //    lat2 = objGPSData.LatGPS - 3 * r;

        //    AxMap1.ConvertCoord(ref x1, ref y1, ref lon1, ref lat1, MapXLib.ConversionConstants.miMapToScreen);
        //    AxMap1.ConvertCoord(ref x2, ref y2, ref lon2, ref lat2, MapXLib.ConversionConstants.miMapToScreen);
        //    Rect = new RectangleF(x1, y1, Math.Abs(x2 - x1), Math.Abs(y2 - y1));
        //    AxMap1.ConvertCoord(ref centerX, ref centerY, ref objGPSData.LonGPS, ref objGPSData.LatGPS, MapXLib.ConversionConstants.miMapToScreen);

        //    CenterPoint = new PointF(centerX, centerY);

        //    //Kích thước hình vẽ cố định 24 x 48 pixel
        //    int width, height;
        //    width = 24;
        //    height = 48;
        //    Rect = new RectangleF(CenterPoint.X - (float)width / 2, CenterPoint.Y - (float)height / 2, width, height);
        //}

        protected override void InitRect()
        {
            float centerX, centerY;
            centerX = centerY = 0;
            AxMap1.ConvertCoord(ref centerX, ref centerY, ref objGPSData.LonGPS, ref objGPSData.LatGPS, MapXLib.ConversionConstants.miMapToScreen);

            CenterPoint = new PointF(centerX, centerY);

            //Kích thước cố định 64 x 64 pixel
            int width, height;
            width = 12;
            height = 24;
            Rect = new RectangleF(CenterPoint.X - (float)width / 2, CenterPoint.Y - (float)height / 2, width, height);
        }

        /// <summary>
        /// Vẽ các tọa độ gps
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            DrawArrow(g, Color.Red);
            //DrawArrow2(g, Color.Red);
            //DrawPlaneImage(g);
        }

        /// <summary>
        /// Vẽ các tọa độ gps
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g, Color color)
        {
            DrawArrow(g, color);
            //DrawPlaneImage(g);
        }
        #endregion

    }
}
